﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Yipusoft.Account.BLL;
using Yipusoft.Account.Model;
using Yipusoft.Common.BLL;
using Yipusoft.Common.Model;
using Yipusoft.Task.BLL;
using Yipusoft.Task.Model;
using System.Text;

public partial class Task_ChartOfWorkload : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            StartDate.Text = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).ToShortDateString();
            EndDate.Text = DateTime.Now.ToShortDateString();
            BindData();
        }
    }
    protected void BindData()
    {
        StringBuilder sql = new StringBuilder();
        sql.Append("Select CreateDepartment,CreateDepartmentName,Sum(InitScore) as Workload From View_Tasks Where ParentId=0");
        sql.Append(" and ((StartDate>='" + StartDate.Text + "' and StartDate<='" + EndDate.Text + "')");
        sql.Append(" or (StartDate<'" + EndDate.Text + "' and EndDate>='" + EndDate.Text + "'))");
        sql.Append(" and Left(CreateDepartment,6)='" + Session["DepartmentID"].ToString().Substring(0, 6) + "'");
        sql.Append(" Group By CreateDepartment,CreateDepartmentName Order By CreateDepartment");
        DataView dv = SplitPage.GetPageData(sql.ToString(),0,1000);

        UserChart.Titles["Title"].Text = "各处室任务工作量分析\n\n" + DateTime.Parse(StartDate.Text).ToLongDateString() + "至" + DateTime.Parse(EndDate.Text).ToLongDateString();
        UserChart.ChartAreas["Default"].AxisX.LabelsAutoFit = false;
        UserChart.Series["工作量"].Points.DataBindXY(dv, "CreateDepartmentName", dv, "Workload");
    }
    protected void ButtonSearch_Click(object sender, EventArgs e)
    {
        BindData();
    }
    protected void ChartList_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ChartList.SelectedValue == "1")
        {
            UserChart.Series["工作量"].Type = Dundas.Charting.WebControl.SeriesChartType.Radar;
        }
        else
        {
            UserChart.Series["工作量"].Type = Dundas.Charting.WebControl.SeriesChartType.Column;
        }
        BindData();
    }
}
